<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@page import="com.fick.tools.SystemLogger"%>
<%@ include file="../tld/tlds.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>河南省公安厅</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="js/meihuaxue.js"></script>
		<script language="javaScript" src="js/prototype.js"></script>
		<script type="text/javascript" src="js/submit.js"></script>
<%
		    int mageid = 0;
		    int phaseid = 0;
		    int editionid = 0;
		 
		    if(request.getParameter("mageid")!=null&&!request.getParameter("mageid").trim().equals("")){
		       mageid = Integer.parseInt(request.getParameter("mageid"));
		    }
		    if(request.getParameter("phaseid")!=null&&!request.getParameter("phaseid").trim().equals("")){
		       phaseid = Integer.parseInt(request.getParameter("phaseid"));
		    }
		    if(request.getParameter("editionid")!=null&&!request.getParameter("editionid").trim().equals("")){
		       editionid = Integer.parseInt(request.getParameter("editionid"));
		    }
		
		
		    //当前页面
			int currPage = 1;
			//总的页数
			int totalPage = 1;
			//一个页面可显示的记录数
			int pageSize = 20;
			//总共有的记录数  
			int totalCount = 1;
			List  li = new ArrayList();
			
			String hql = "";
			String counthql ="select count(*) from Magecontent "; 
			if(request.getParameter("mageid")!=null&&!request.getParameter("mageid").trim().equals(""))
			{
				hql+=" where mageid = '"+mageid+"'";
				counthql+=" where mageid = '"+mageid+"'";
			}
			if(request.getParameter("phaseid")!=null&&!request.getParameter("phaseid").trim().equals(""))
			{
				hql+=" and phaseid = '"+phaseid+"'";
				counthql+=" and phaseid = '"+phaseid+"'";
			}
			if(request.getParameter("editionid")!=null&&!request.getParameter("editionid").trim().equals(""))
			{
				hql+=" and mageedition.editionid = '"+editionid+"'";
				counthql+=" and mageedition.editionid = '"+editionid+"'";
			}
			hql+=" order by conid";
			MagecontentDAO magecontentDAO = new MagecontentDAO();
			Magecontent magecontent = new Magecontent();
			totalCount = (Integer)magecontentDAO.getSession().createQuery(counthql).uniqueResult();
			totalCount=3;
			//得到总的页数
			if(totalCount > pageSize){
			   totalPage = totalCount/pageSize+1;
			   }else{
			   totalPage = 1;
			   }
			
			//判断是否是传过来页数
			if(request.getParameter("currPage") != null){
			   currPage = Integer.parseInt(request.getParameter("currPage"));
			   if(currPage<1){
			     currPage=1;
			    }
			   if(currPage >totalPage){
			     currPage = totalPage;
			   }
			} 
			//得到记录数
			li = null;
			  li = magecontentDAO.findPageByHql(hql,currPage,pageSize);
%>
</head>

<body>
<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD">


    
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
          <td width="6%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">选择</td>
          <td width="54%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">标题</td>
          <td width="12%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">时间</td>
       <td width="10%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">操作</td>
        </tr>
        <%
		   for(int i = 0 ; i < li.size(); i++){
			  magecontent = (Magecontent)li.get(i);
		 %>
		<tr>
          <td width="6%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		 <input type="checkbox" name="MyCheckBox" id="MyCheckBox" value="<%=magecontent.getConid() %>" />
		  </td>
          <td width="54%" height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%
									
			if(magecontent.getTitle().length()>20){										        	
			   out.print(magecontent.getTitle().substring(0,20));
			 }else{
				out.print(magecontent.getTitle());
			 }
		   %>
		  
		  </td>
          <td width="12%" height="25" align="center" valign="middle" bgcolor="#FFFFFF"><%=magecontent.getAdddate().toString().substring(0,10) %></td>
          <td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		  <a href="upMagecon.jsp?contentid=<%=magecontent.getConid() %>">修改/查看</a>&nbsp;
<a href="<%=request.getContextPath()%>/admin/manageMagecontent.do?method=delMagecon&contentid=<%=magecontent.getConid() %>">删除</a>
		  </td>
        </tr>
		<%
			}
		%>
		
	
        
		
      </table>
	    <table width="98%" border="0" cellspacing="0" cellpadding="0">
	  	<tr>
			 <td height="45" align="left" valign="middle">
  <input type="button" name="selectAlls" id="selectAlls" value="全选" onclick="return selectAll()" />
  <input type="button" name="noSelectAll" id="noSelectAll" value="反选" onclick="return selectOthers();" />
  <input type="button" name="cancelSelects" id="cancelSelects" value="取消选择" onclick="return cancelSelect();" />
  <input type="button" name="delAlls" id="delAlls" value="全部删除" onclick="return delAllMagecon();"/>
										   	  	
			</td>
		</tr>
	  </table>
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="45" align="center" valign="middle">
		  共有［<%=totalPage %>］页 当前是第［<%=currPage %>］页 [
<a href="contentList.jsp?currPage=1&mageid=<%=mageid%>&phaseid=<%=phaseid %>&editionid=<%=editionid %>" class="page">首页</a>][
<a href="contentList.jsp?currPage=<%=currPage-1 %>&mageid=<%=mageid%>&phaseid=<%=phaseid %>&editionid=<%=editionid %>"
	class="page">上一页</a>][
<a href="contentList.jsp?currPage=<%=currPage+1 %>&mageid=<%=mageid%>&phaseid=<%=phaseid %>&editionid=<%=editionid %>"
	class="page">下一页</a>][
<a href="contentList.jsp?currPage=<%=totalPage %>&mageid=<%=mageid%>&phaseid=<%=phaseid %>&editionid=<%=editionid %>"
	class="page">尾页</a>]
<input type="button" value="GO" onclick="isDigit()" />
<input type="text" size="1" name="currPage" id="currPage"/>
		 </td>
        </tr>
      </table>
</table>
</body>
</html>
<script type="text/javascript">
<!--
var message = "<%=request.getAttribute("message")%>";
if(message!=null && message!="null" && message !=""){
   alert(message);
  }
//-->
</script>
<%
	request.removeAttribute("message");
%>
